const upload = (url, file) => {
    return new Promise((resolve, reject) => {
        const formData = new FormData();
        formData.append('files', file);
        fetch(url, {
            method: 'POST',
            body: formData,
        }).then(response => {
            if (!response.ok) {
                throw new Error('Network response was not ok');
            }
            return response.json();
        }).then(data => {
            resolve(data);
        }).catch(error => {
            reject(error)
        });
    });
};

export default upload;